package com.dream.tihai.controller;

import com.dream.tihai.entity.ProblemEntity;
import com.dream.tihai.service.IProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Valley
 * Created by Valley on 2022/12/14
 */
@RestController
@RequestMapping("problem")
@CrossOrigin
public class ProblemController {

    @Autowired
    IProblemService problemService;

    /** 根据类型、标题查询problem列表 */
    @RequestMapping("selectProblemList")
    public List<ProblemEntity> selectProblemList(ProblemEntity problem) throws Exception {
        List<ProblemEntity> problems = problemService.selectProblemList(problem);
        return problems;
    }

    @RequestMapping("submitProblem")
    public void submitProblem(@RequestBody ProblemEntity problem) throws Exception {
        System.out.println(problem);
        boolean result = problemService.submitProblem(problem);
    }

}
